
<?php
echo $this->Html->script('nav/switchNavigation');
echo $this->Html->script('jwplayer/jwplayer');

$usersVideo = $video['UsersVideo'];
$user = $video['User'];
$filename = $usersVideo['filename'];
?>

<script type="text/javascript">
    $(document).ready(function(){
        jwplayer("videoContainer").setup({
            flashplayer: "<?php echo $this->webroot;?>players/player.swf",
            file: "<?php echo $this->webroot;?>uploads/videos/<?php echo $filename;?>",
            height: 351,
            width: 624
        });
    });
</script>



<style>
    .video{
        width : 58%;
        height : 400px;
    }
</style>



<div>
    <h2> <?php echo $usersVideo['title'];?> </h2>
    
    <div class="video col6 left">
        
        <div id="videoContainer">
            Loading the player ...
        </div>
    </div>
    <div class="col4 right">
        <p>
            Posté par : <?php echo $this->Display->userLink($user);?>
        </p>
        <p>
            Le : <?php echo $this->Date->getDisplay($usersVideo['posted_on']);?>
        </p>
        <p>
            Type : <?php echo $this->Display->usersVideosType($usersVideo['type']);?>
        </p>
        <?php
        $usersVideosInfo = $video[$usersVideo['type']];
        if ($usersVideo['type'] == 'VideosTutorial'){
            ?>
            <h4><?php echo $this->Display->videosTutorialLink($usersVideosInfo['VideosTutorial']);?></h4>
            <p>
                <?php echo $usersVideosInfo['VideosTutorial']['description'];?>
            </p>
            <p>
                Figure : <?php echo 'TODO : Afficher la figure';?>
            </p>
            <p>
                Module : <?php echo 'TODO : Afficher le type de module';?>
            </p>
            <?php
        }
        else if ($usersVideo['type'] == 'VideosTrick'){
            ?>
            <h4><?php echo $this->Display->videosTrickLink($usersVideosInfo['VideosTrick']);?></h4>
            <p>
                <?php echo $usersVideosInfo['VideosTrick']['description'];?>
            </p>
            <p>
                Figure : <?php echo 'TODO : Afficher la figure';?>
            </p>
            <p>
                Module : <?php echo 'TODO : Afficher le type de module';?>
            </p>
            <?php
            
        }
        else if ($usersVideo['type'] == 'VideosEditing'){
            ?>
            <h4><?php echo $this->Display->videosEditingLink($usersVideosInfo['VideosEditing']);?></h4>
            <p>
                <?php echo $usersVideosInfo['VideosEditing']['description'];?>
            </p>
            <p>
                Tag : <?php echo 'TODO : Afficher les tags';?>
            </p>
            <p>
                Staf : <?php echo 'TODO : Afficher les personnes de la vidéo';?>
            </p>
            <?php
            
        }
        
        ?>
    </div>
</div>


<div class="clear">
    <div class="switchNavigation">
        <div class="navSwitch">
            
        </div>
        <div class="item" id="sn-advice">
            <h3 class="title">Advices</h3>
            <div id="advicesAnswerContent">
            
            </div>
           
             <?php

                echo $this->Form->create('VideosAdvicesAnswer');
                echo $this->Form->input('content', array(
                    'type' => 'textarea',
                    'label' => 'Proposer un conseil'
                ));
                echo $this->Form->end('Post');

                ?>
        </div>
        <div class="item" id="sn-comment">
            <h3 class="title">Comments</h3>
            
            <div id="commentContent">
            
            </div>
            
            <?php

                echo $this->Form->create('UsersVideosComment');
                echo $this->Form->input('UsersVideosComment.content', array(
                    'type' => 'textarea',
                    'label' => 'Comment'
                ));
                echo $this->Form->end('Post');

                ?>
        </div>
    </div>
</div>

<script type="text/javascript">

$(document).ready(function(){
    var videoId = <?php echo $usersVideo['id'];?>;
    
    $.ajax({
        url : '<?php echo $this->webroot;?>UsersVideosComments/getPaginatedComments/' + videoId,
        success : function(data){
            $('#commentContent').html(data);
            
        }
    });
    $.ajax({
        url : '<?php echo $this->webroot;?>VideosAdvicesAnswers/getPaginatedAnswers/' + videoId,
        success : function(data){
            $('#advicesAnswerContent').html(data);
            
        }
    });
    
});
</script>

